package com.mgm.constant;

public enum APICode {
	
	SUCCESS(0, "success"), PARAMETER_ERROR(10, "Parameter error"), PARAMETER_MISMATCH(20,
			"token and affid do not match"), ERROR(50, "Server error");
	
	private int code; //编码
	
	private String message; //消息

	private APICode(int code, String message) {
		this.code = code;
		this.message = message;
	}
	
	/**
	 * 根据code获取消息 
	 * @Title: getName   
	 * @Description: TODO(...)   
	 * @param: @param code
	 * @param: @return      
	 * @return: String      
	 * @throws
	 */
    public static String getName(int code) {  
        for (APICode c : APICode.values()) {  
            if (c.getCode() == code) {  
                return c.message;  
            }  
        }  
        return null;  
    }

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}
    
}
